package com.sg.service.biz.finance.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.finance.req.*;
import com.sg.dto.biz.finance.res.*;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class InterfaceModeServiceImpl
        implements com.wicket.okrfinance.biz.service.InterfaceModeService {

    @Resource
    private RedisUtil redisUtil;
    //@Resource
    //private MSpaceService mSpaceService;
    @Resource
    private NbInterfaceMode nbInterfaceMode;

    /**
     * D7查询内存业务数据详情(公共)[9778]
     * gen by moon at 6/9/2024, 4:44:42 PM
     */
    @Trace(operationName = "D7查询内存业务数据详情(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryMemoryBusinessSevenDataDetailComRespDto queryMemoryBusinessSevenDataDetailCom(QueryMemoryBusinessSevenDataDetailComReqDto reqDto) {


        QueryMemoryBusinessDataDetailComRespDto queryMemoryBusinessDataRes_1 = null;
//步骤0: M7查询内存业务数据详情（特殊方法） - queryMemoryBusinessDataDetailCom
        //ModelCode: queryMemoryBusinessData
        QueryMemoryBusinessDataDetailComRespDto queryMemoryBusinessDataRes = null;
        QueryMemoryBusinessDataDetailComReqDto queryMemoryBusinessDataReq = new QueryMemoryBusinessDataDetailComReqDto();
        if (reqDto != null) {
            queryMemoryBusinessDataReq.setDataObjectBatchCode(reqDto.getDataObjectBatchCode());//SimpleFieldAssign//sourceId:1859765_1
            queryMemoryBusinessDataReq.setBusinessDataObject(reqDto.getBusinessDataObject());//SimpleFieldAssign//sourceId:1859766_1
            queryMemoryBusinessDataReq.setMemoryBusinessResDataList(reqDto.getMemoryBusinessResDataList().stream().map(item -> BeanUtil.toBean(item, MemoryBusinessResDataDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1859767_1
        }

        /*M7查询内存业务数据详情（特殊方法）[9777]   */
        Assert.isNull(queryMemoryBusinessDataReq.getDataObjectBatchCode(), "D7查询内存业务数据详情(公共)-M7查询内存业务数据详情（特殊方法）-数据对象批次标识不能为空", false);
        Assert.isNull(queryMemoryBusinessDataReq.getBusinessDataObject(), "D7查询内存业务数据详情(公共)-M7查询内存业务数据详情（特殊方法）-业务数据对象不能为空", false);
        queryMemoryBusinessDataRes = nbInterfaceMode.queryMemoryBusinessDataDetailCom(queryMemoryBusinessDataReq);


        queryMemoryBusinessDataRes_1 = queryMemoryBusinessDataRes;

        QueryMemoryBusinessSevenDataDetailComRespDto retData = new QueryMemoryBusinessSevenDataDetailComRespDto();
        if (queryMemoryBusinessDataRes_1 != null) {
            retData.setCustomField1(queryMemoryBusinessDataRes_1.getCustomField1());//SimpleFieldAssign//sourceId:1859827_1
            retData.setCustomField2(queryMemoryBusinessDataRes_1.getCustomField2());//SimpleFieldAssign//sourceId:1859828_1
            retData.setCustomField3(queryMemoryBusinessDataRes_1.getCustomField3());//SimpleFieldAssign//sourceId:1859829_1
            retData.setCustomField4(queryMemoryBusinessDataRes_1.getCustomField4());//SimpleFieldAssign//sourceId:1859830_1
            retData.setCustomField5(queryMemoryBusinessDataRes_1.getCustomField5());//SimpleFieldAssign//sourceId:1859831_1
            retData.setCustomField6(queryMemoryBusinessDataRes_1.getCustomField6());//SimpleFieldAssign//sourceId:1859832_1
            retData.setCustomField7(queryMemoryBusinessDataRes_1.getCustomField7());//SimpleFieldAssign//sourceId:1859833_1
            retData.setCustomField8(queryMemoryBusinessDataRes_1.getCustomField8());//SimpleFieldAssign//sourceId:1859834_1
            retData.setCustomField9(queryMemoryBusinessDataRes_1.getCustomField9());//SimpleFieldAssign//sourceId:1859835_1
            retData.setCustomField10(queryMemoryBusinessDataRes_1.getCustomField10());//SimpleFieldAssign//sourceId:1859836_1
            retData.setCustomField11(queryMemoryBusinessDataRes_1.getCustomField11());//SimpleFieldAssign//sourceId:1859837_1
            retData.setCustomField12(queryMemoryBusinessDataRes_1.getCustomField12());//SimpleFieldAssign//sourceId:1859838_1
            retData.setCustomField13(queryMemoryBusinessDataRes_1.getCustomField13());//SimpleFieldAssign//sourceId:1859839_1
            retData.setCustomField14(queryMemoryBusinessDataRes_1.getCustomField14());//SimpleFieldAssign//sourceId:1859840_1
            retData.setCustomField15(queryMemoryBusinessDataRes_1.getCustomField15());//SimpleFieldAssign//sourceId:1859841_1
            retData.setCustomField16(queryMemoryBusinessDataRes_1.getCustomField16());//SimpleFieldAssign//sourceId:1859842_1
            retData.setCustomField17(queryMemoryBusinessDataRes_1.getCustomField17());//SimpleFieldAssign//sourceId:1859843_1
            retData.setCustomField18(queryMemoryBusinessDataRes_1.getCustomField18());//SimpleFieldAssign//sourceId:1859844_1
            retData.setCustomField19(queryMemoryBusinessDataRes_1.getCustomField19());//SimpleFieldAssign//sourceId:1859845_1
            retData.setCustomField20(queryMemoryBusinessDataRes_1.getCustomField20());//SimpleFieldAssign//sourceId:1859846_1
            retData.setCustomField21(queryMemoryBusinessDataRes_1.getCustomField21());//SimpleFieldAssign//sourceId:1859847_1
            retData.setCustomField22(queryMemoryBusinessDataRes_1.getCustomField22());//SimpleFieldAssign//sourceId:1859848_1
            retData.setCustomField23(queryMemoryBusinessDataRes_1.getCustomField23());//SimpleFieldAssign//sourceId:1859849_1
            retData.setCustomField24(queryMemoryBusinessDataRes_1.getCustomField24());//SimpleFieldAssign//sourceId:1859850_1
            retData.setCustomField25(queryMemoryBusinessDataRes_1.getCustomField25());//SimpleFieldAssign//sourceId:1859851_1
            retData.setCustomField26(queryMemoryBusinessDataRes_1.getCustomField26());//SimpleFieldAssign//sourceId:1859852_1
            retData.setCustomField27(queryMemoryBusinessDataRes_1.getCustomField27());//SimpleFieldAssign//sourceId:1859853_1
            retData.setCustomField28(queryMemoryBusinessDataRes_1.getCustomField28());//SimpleFieldAssign//sourceId:1859854_1
            retData.setCustomField29(queryMemoryBusinessDataRes_1.getCustomField29());//SimpleFieldAssign//sourceId:1859855_1
            retData.setCustomField30(queryMemoryBusinessDataRes_1.getCustomField30());//SimpleFieldAssign//sourceId:1859856_1
            retData.setCustomField31(queryMemoryBusinessDataRes_1.getCustomField31());//SimpleFieldAssign//sourceId:1859857_1
            retData.setCustomField32(queryMemoryBusinessDataRes_1.getCustomField32());//SimpleFieldAssign//sourceId:1859858_1
            retData.setCustomField33(queryMemoryBusinessDataRes_1.getCustomField33());//SimpleFieldAssign//sourceId:1859859_1
            retData.setCustomField34(queryMemoryBusinessDataRes_1.getCustomField34());//SimpleFieldAssign//sourceId:1859860_1
            retData.setCustomField35(queryMemoryBusinessDataRes_1.getCustomField35());//SimpleFieldAssign//sourceId:1859861_1
            retData.setCustomField36(queryMemoryBusinessDataRes_1.getCustomField36());//SimpleFieldAssign//sourceId:1859862_1
            retData.setCustomField37(queryMemoryBusinessDataRes_1.getCustomField37());//SimpleFieldAssign//sourceId:1859863_1
            retData.setCustomField38(queryMemoryBusinessDataRes_1.getCustomField38());//SimpleFieldAssign//sourceId:1859864_1
            retData.setCustomField39(queryMemoryBusinessDataRes_1.getCustomField39());//SimpleFieldAssign//sourceId:1859865_1
            retData.setCustomField40(queryMemoryBusinessDataRes_1.getCustomField40());//SimpleFieldAssign//sourceId:1859866_1
            retData.setCustomField41(queryMemoryBusinessDataRes_1.getCustomField41());//SimpleFieldAssign//sourceId:1859867_1
            retData.setCustomField42(queryMemoryBusinessDataRes_1.getCustomField42());//SimpleFieldAssign//sourceId:1859868_1
            retData.setCustomField43(queryMemoryBusinessDataRes_1.getCustomField43());//SimpleFieldAssign//sourceId:1859869_1
            retData.setCustomField44(queryMemoryBusinessDataRes_1.getCustomField44());//SimpleFieldAssign//sourceId:1859870_1
            retData.setCustomField45(queryMemoryBusinessDataRes_1.getCustomField45());//SimpleFieldAssign//sourceId:1859871_1
            retData.setCustomField46(queryMemoryBusinessDataRes_1.getCustomField46());//SimpleFieldAssign//sourceId:1859872_1
            retData.setCustomField47(queryMemoryBusinessDataRes_1.getCustomField47());//SimpleFieldAssign//sourceId:1859873_1
            retData.setCustomField48(queryMemoryBusinessDataRes_1.getCustomField48());//SimpleFieldAssign//sourceId:1859874_1
            retData.setCustomField49(queryMemoryBusinessDataRes_1.getCustomField49());//SimpleFieldAssign//sourceId:1859875_1
            retData.setCustomField50(queryMemoryBusinessDataRes_1.getCustomField50());//SimpleFieldAssign//sourceId:1859876_1
            retData.setCustomField51(queryMemoryBusinessDataRes_1.getCustomField51());//SimpleFieldAssign//sourceId:1859877_1
            retData.setCustomField52(queryMemoryBusinessDataRes_1.getCustomField52());//SimpleFieldAssign//sourceId:1859878_1
            retData.setCustomField53(queryMemoryBusinessDataRes_1.getCustomField53());//SimpleFieldAssign//sourceId:1859879_1
            retData.setCustomField54(queryMemoryBusinessDataRes_1.getCustomField54());//SimpleFieldAssign//sourceId:1859880_1
            retData.setCustomField55(queryMemoryBusinessDataRes_1.getCustomField55());//SimpleFieldAssign//sourceId:1859881_1
            retData.setCustomField56(queryMemoryBusinessDataRes_1.getCustomField56());//SimpleFieldAssign//sourceId:1859882_1
        }


        return retData;
    }

    /**
     * D7新增内存业务数据(公共)[9783]
     * gen by moon at 6/9/2024, 4:45:26 PM
     */
    @Trace(operationName = "D7新增内存业务数据(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddMemoryBusinessSevenDataComRespDto addMemoryBusinessSevenDataCom(AddMemoryBusinessSevenDataComReqDto reqDto) {


        //步骤0: M7新增内存业务数据（特殊方法） - addMemoryBusinessSevenData
        //ModelCode: addMemoryBusinessData
        AddMemoryBusinessSevenDataRespDto addMemoryBusinessDataRes = null;
        AddMemoryBusinessSevenDataReqDto addMemoryBusinessDataReq = new AddMemoryBusinessSevenDataReqDto();
        if (reqDto != null) {
            addMemoryBusinessDataReq.setDataObjectBatchCode(reqDto.getDataObjectBatchCode());//SimpleFieldAssign//sourceId:1860936_1
            addMemoryBusinessDataReq.setBusinessDataObject(reqDto.getBusinessDataObject());//SimpleFieldAssign//sourceId:1860935_1
            addMemoryBusinessDataReq.setIsDataList(reqDto.getIsDataList());//SimpleFieldAssign//sourceId:1860937_1
        }
        if (reqDto != null && reqDto.getMemoryBusinessDataList() != null && !CollectionUtil.isEmpty(reqDto.getMemoryBusinessDataList())) {
            addMemoryBusinessDataReq.setMemoryBusinessDataList(reqDto.getMemoryBusinessDataList().stream().map(item -> BeanUtil.toBean(item, MemoryBusinessDataDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1860938_1
        }

        /*M7新增内存业务数据（特殊方法）[9782]   */
        Assert.isNull(addMemoryBusinessDataReq.getDataObjectBatchCode(), "D7新增内存业务数据(公共)-M7新增内存业务数据（特殊方法）-数据对象批次标识不能为空", false);
        Assert.isNull(addMemoryBusinessDataReq.getBusinessDataObject(), "D7新增内存业务数据(公共)-M7新增内存业务数据（特殊方法）-业务数据对象不能为空", false);
        Assert.isNull(addMemoryBusinessDataReq.getIsDataList(), "D7新增内存业务数据(公共)-M7新增内存业务数据（特殊方法）-是否是数据集对象不能为空", false);
        addMemoryBusinessDataRes = nbInterfaceMode.addMemoryBusinessSevenData(addMemoryBusinessDataReq);


        AddMemoryBusinessSevenDataComRespDto retData = new AddMemoryBusinessSevenDataComRespDto();


        return retData;
    }

    /**
     * D7执行底层框架公共字段推送内存(公共)[10508]
     * gen by moon at 3/12/2025, 5:31:08 PM
     */
    @Trace(operationName = "D7执行底层框架公共字段推送内存(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ImplementBottomPublicFieldPushMemoryComRespDto implementBottomPublicFieldPushMemoryCom(ImplementBottomPublicFieldPushMemoryComReqDto reqDto) {


        //步骤0: M7执行底层框架公共字段推送内存（特殊方法） - implementPublicFieldPushMemory
        //ModelCode: publicFieldCache
        ImplementPublicFieldPushMemoryRespDto publicFieldCacheRes = null;
        ImplementPublicFieldPushMemoryReqDto publicFieldCacheReq = new ImplementPublicFieldPushMemoryReqDto();
        if (reqDto != null) {
            publicFieldCacheReq.setCreateInductionId(reqDto.getCreateInductionId());//SimpleFieldAssign//sourceId:2042142_1
            publicFieldCacheReq.setOperationInductionId(reqDto.getOperationInductionId());//SimpleFieldAssign//sourceId:2042141_1
            publicFieldCacheReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:2042143_1
            publicFieldCacheReq.setAppId(reqDto.getAppId());//SimpleFieldAssign//sourceId:2042144_1
        }

        /*M7执行底层框架公共字段推送内存（特殊方法）[10509]  用于定时任务执行时，获取定时任务执行所需的公共信息，存入缓存，供定时任务中虚拟用况使用 */
        Assert.isNull(publicFieldCacheReq.getCreateInductionId(), "D7执行底层框架公共字段推送内存(公共)-M7执行底层框架公共字段推送内存（特殊方法）-创建人就职记录ID不能为空", false);
        Assert.isNull(publicFieldCacheReq.getOperationInductionId(), "D7执行底层框架公共字段推送内存(公共)-M7执行底层框架公共字段推送内存（特殊方法）-操作人就职记录ID不能为空", false);
        Assert.isNull(publicFieldCacheReq.getSpaceId(), "D7执行底层框架公共字段推送内存(公共)-M7执行底层框架公共字段推送内存（特殊方法）-创建于空间ID不能为空", false);
        Assert.isNull(publicFieldCacheReq.getAppId(), "D7执行底层框架公共字段推送内存(公共)-M7执行底层框架公共字段推送内存（特殊方法）-创建于联盟应用ID不能为空", false);
        publicFieldCacheRes = nbInterfaceMode.implementPublicFieldPushMemory(publicFieldCacheReq);


        ImplementBottomPublicFieldPushMemoryComRespDto retData = new ImplementBottomPublicFieldPushMemoryComRespDto();


        return retData;
    }
//@Resource
    //private MCustomFields4Service mCustomFields4Service;

    //
}
